package Java1226;
//1创建类
public class Student {
    //2成员变量
    String name;
    int age;
    // 先生成 3 构造方法

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //4 生成 getter 和setter方法

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    //5 生成 tostring方法   打印对象信息用


    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    //6 类中main方法创建对象
    public static void main(String[] args) {
        Student s1 = new Student();
        s1.setName("sam");
        s1.setAge(18);
        System.out.println(s1.name);
        Student s2 = new Student("kack", 33);
        System.out.println(s2);

    }
}
